// 注意：async在这里指的是第三方模块，而不是es7中的async/await

// 只是形式上相对于嵌套回调来说做了简化
var async = require('async')
var fs = require('fs')
function read_foo (callback) {
  fs.readFile('../foo.txt', 'utf-8', callback)
}
function read_bar (callback) {
  fs.readFile('../bar.txt', 'utf-8', callback)
}
function read_baz (callback) {
  fs.readFile('../baz.txt', 'utf-8', callback)
}
async.series([read_foo, read_bar, read_baz], (err, data) => { // 异步方法
  console.log(data[0].toString())
  console.log(data[1].toString())
  console.log(data[2].toString())
})

console.log('______________________') // 最先打印
async.parallel([read_foo, read_bar, read_baz], (err, data) => { // 异步方法
  console.log(data[0].toString())
  console.log(data[1].toString())
  console.log(data[2].toString())
})